package com.example.demo.controller;

import com.example.demo.dto.UserDTO;
import com.example.demo.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class UserController {

    @Autowired
    private UserService userService;

    private Logger log = LoggerFactory.getLogger(UserController.class);

    @GetMapping
    public String getUserName(){
        return userService.getUserName();
    }

    @GetMapping("userName")
    public String getUserName2(@RequestParam(value = "name",defaultValue = "小白")String name){
        log.info("UserController-getUserName2-入参-get请求：{}",name);
        return userService.getUserName();
    }

    @PostMapping("name")
    public String getUserName3(@RequestBody UserDTO userDTO){
        log.info("UserController-getUserName3-入参-post请求：{}",userDTO.getUserName());
        return userService.getUserName();
    }


}
